package com.iot.websocket.message;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iot.common.constant.EqConstants;
import com.iot.common.enums.BizCode;
import com.iot.websocket.Todo;
import com.iot.websocket.WebSocketMessage;

/**
 * @author Cao.ning
 * @date 2022/7/4
 */
public class MqttClientMessage extends WebSocketMessage {

    private String todo;

    public MqttClientMessage() {
        this.setBizCode(BizCode.PUBLISH.getCode());
    }

    public static MqttClientMessage getInstance(String message){
        MqttClientMessage mqttClientMessage = JSON.parseObject(message, MqttClientMessage.class);
        return handle(mqttClientMessage);
    }

    public static MqttClientMessage handle(MqttClientMessage mqttClientMessage){
        JSONObject data = new JSONObject();
        data.put("todo", mqttClientMessage.getTodo());
        switch (mqttClientMessage.getTodo()){
            case Todo.SET_CONFIG:
                mqttClientMessage = null;
                break;
            default:
                mqttClientMessage = null;
                break;
        }
        return mqttClientMessage;
    }

    public void setTodo(String todo) {
        this.todo = todo;
    }

    public String getTodo() {
        return todo;
    }
}
